package com.chenlonghai.sbmybatis.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.chenlonghai.sbmybatis.dao.BannerDao;
import com.chenlonghai.sbmybatis.entity.Banner;
import com.chenlonghai.sbmybatis.service.BannerService;

@Service
public class BannerServiceImpl implements BannerService {
  @Autowired
  private BannerDao bannerDao;
  
	@Override
	public List<Banner> queryBanner() {
		// TODO Auto-generated method stub
		return bannerDao.queryBanner();
	}

	@Override
	public List<Banner> queryBannerByType(String type) {
		// TODO Auto-generated method stub
		return bannerDao.queryBannerByType(type);
	}

	@Override
	public boolean addBannner(Banner banner) {
		// TODO Auto-generated method stub
		boolean isOK = false;
		int row = bannerDao.addBannner(banner);
		if (row > 0) {
			isOK = true;
		}else{
			isOK = false;
		}
		
		return isOK;
	}

	@Override
	public boolean deleteBannerById(int id) {
		// TODO Auto-generated method stub
		boolean isOK = false;
		int row = bannerDao.deleteBannerById(id);
		if (row > 0) {
			isOK = true;
		}else{
			isOK = false;
		}
		
		return isOK;
	}

	@Override
	public boolean updateBanner(Banner banner) {
		// TODO Auto-generated method stub
	
		return bannerDao.updateBanner(banner) >0;
	}

	@Override
	public Banner queryBannerById(int id) {
		// TODO Auto-generated method stub
		return bannerDao.queryBannerById(id);
	}

}
